package com.hundsun.fcp.activity;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.View.OnClickListener;

import com.hundsun.fcp.R;
import com.hundsun.fcp.adapter.MsgCenterAdapter;
import com.hundsun.fcp.base.BaseActivity;
import com.hundsun.fcp.common.utils.DensityUtil;
import com.hundsun.fcp.dialog.UIActionSheetDialog;
import com.hundsun.fcp.dialog.UIActionSheetDialog.OnSheetItemClickListener;
import com.hundsun.fcp.widget.swipelistview.SwipeMenu;
import com.hundsun.fcp.widget.swipelistview.SwipeMenuCreator;
import com.hundsun.fcp.widget.swipelistview.SwipeMenuItem;
import com.hundsun.fcp.widget.swipelistview.SwipeMenuListView;
import com.hundsun.fcp.widget.swipelistview.SwipeMenuListView.OnMenuItemClickListener;

public class MineMsgCenterActivity extends BaseActivity {
	private MsgCenterAdapter mAdapter;

	private SwipeMenuListView mListView;

	private SwipeMenuCreator creator;

	@Override
	protected int getContentLayout() {
		return R.layout.fcp_mine_msg_center;
	}

	@Override
	protected void initHeader() {
		super.initHeader();
		mHeaderMenu.setTitle(R.string.mine_msg_center);
		mHeaderMenu.setRightBG(R.drawable.fcp_more);
		mHeaderMenu.setRightClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				initMenu();
			}
		});
	}

	@Override
	public void initView() {
		super.initView();
		mListView = (SwipeMenuListView) findViewById(R.id.lv_msg_center);
		mAdapter = new MsgCenterAdapter(this);
		mListView.setAdapter(mAdapter);
		initSwipeMenuCreator();
		initSwipeListView();
	}


	private void initSwipeListView() {
		mListView.setMenuCreator(creator);
		mListView.setOnMenuItemClickListener(new OnMenuItemClickListener() {
			@Override
			public boolean onMenuItemClick(int position, SwipeMenu menu,
					int index) {
				// BankBean item = mAdapter.getItem(position);
				
				return false;
			}
		});
	}

	/**
	 * 弹出底部菜单
	 */

	public void initMenu() {
		final UIActionSheetDialog dialog = new UIActionSheetDialog(
				MineMsgCenterActivity.this);
		dialog.addSheetItem("全部标记为已读", Color.BLUE, new OnSheetItemClickListener() {
			@Override
			public void onClick() {
				// TODO Auto-generated method stub
				
			}
		});
		dialog.addSheetItem("清空", Color.RED, new OnSheetItemClickListener() {
			@Override
			public void onClick() {
				// TODO Auto-generated method stub
				
			}
		});
		dialog.show();

	}

	/**
	 * 创建侧滑菜单
	 */
	private void initSwipeMenuCreator() {
		creator = new SwipeMenuCreator() {

			@Override
			public void create(SwipeMenu menu) {
				// create "open" item
				SwipeMenuItem deleteItem = new SwipeMenuItem(
						getApplicationContext());
				// set item background
				deleteItem.setBackground(new ColorDrawable(getResources()
						.getColor(R.color.red_main_color)));
				// set item width
				deleteItem.setWidth(DensityUtil.dip2px(
						MineMsgCenterActivity.this, 70));
				// set item title
				deleteItem.setTitle("删除");
				// set item title fontsize
				deleteItem.setTitleSize(18);
				// set item title font color
				deleteItem.setTitleColor(Color.WHITE);
				// add to menu
				menu.addMenuItem(deleteItem);

			}
		};
	}

}
